package ua.epam.muzalevskiy.traction.configuretion;

import java.util.ResourceBundle;
import org.apache.log4j.Logger;

/**
 * <code>PagePathConfigurer</code> configures resources that correspond to
 * user the path of required page.
 *
 * @author Muzalevskiy Vitaliy
 */
public class PagePathConfigurer {
    /** logger is used for logging PagePathsConfigurer class */ 
    private static Logger logger = Logger.getLogger(PagePathConfigurer.class);
    /** Single instance of <code>PagePathConfigurer</code> class.*/
    private static PagePathConfigurer instance;
    /** resourceBundle is used to get resources from the specified properties file*/
    private ResourceBundle resourceBundle;
    /** BUNDLE_NAME specifies the name of the properties file */
    private static final String BUNDLE_NAME = "pagepath";
    public static final String ERROR_PAGE = "ERROR_PAGE";
    public static final String FIND_ROUTE_PAGE = "FIND_ROUTE_PAGE";
    public static final String FIND_ROUTE_RESULT_PAGE = "FIND_ROUTE_RESULT_PAGE";
    public static final String INDEX_PAGE = "INDEX_PAGE";
    public static final String NEW_USER_PAGE = "NEW_USER_PAGE";   
    public static final String NEW_USER_RESULT_PAGE = "NEW_USER_RESULT_PAGE";
    public static final String ROUTE_INFO_PAGE = "ROUTE_INFO_PAGE";
    public static final String ROUTE_INFO_RESULT_PAGE = "ROUTE_INFO_RESULT_PAGE";
    public static final String SCHEDULE_PAGE = "SCHEDULE_PAGE";
    public static final String SCHEDULE_RESULT_PAGE = "SCHEDULE_RESULT_PAGE";
    public static final String ADMINISTRATION_PAGE = "ADMINISTRATION_PAGE";
    public static final String NEW_VEHICLE_PAGE = "NEW_VEHICLE_PAGE";
    public static final String ADD_VEHICLE_TO_ROURE_PAGE = "ADD_VEHICLE_TO_ROURE_PAGE";
    
    public static PagePathConfigurer getInstance() {
        /*
         * this method realizes the Singleton pattern. this method returns the
         * only reference to the PagePathsConfigurer object.
         */
        if (instance == null) {
            instance = new PagePathConfigurer();
            instance.resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
            logger.info("Resource bundle complete");
        }
        return instance;
    }

    /**
     * Get path to the page in accordance to entered key.
     *
     * @param key - <code>String</code> value of key to property file in
     *      which required page path stored.
     * @return <code>String</code> value of path to the page.
     */
    public String getProperty(String key) {
        return (String)resourceBundle.getObject(key);
    }
}
